<template>
  <div>
    <md-field>
      <md-input-item ref="name" type="phone" title="手机号" v-model="phone" placeholder="请输入手机号" clearable is-title-latent>
      </md-input-item>
      <md-button class="loginBtn" :type="loginLodingFlag?'disabled':'primary'" @click="login()">一键登陆</md-button>
    </md-field>
  </div>
</template>

<script>
import {
  Button,
  InputItem,
  Field,
  Toast
} from 'mand-mobile'
import {
  validator
} from '@/utils/common'
import onePass from '@/utils/onePass'
  export default {
    name : 'onePass' ,
    data () {
      return {
        phone: '', // 手机号
      }
    } ,
    components : {
      [Field.name]: Field,
      [InputItem.name]: InputItem,
      [Button.name]: Button,
      [Toast.name]: Toast
    } ,
    computed: {
      loginLodingFlag() {
        if(validator.isMobile(this.phone)) {
          return false
        } else {
          return false
        }
      }
    },
    methods : {
      login() {
        onePass({
          mobile: this.phone,
          system: 'TEST',
          businessType: 'MOBILE_ONE_PASS_TEST'
        }).then(res => {
          console.log(res)
          if(res.code == '0') {
            Toast.info('成功')
          }
          if(res.code == '1') {
            Toast.info('失败')
          }
          if(res.code == '2') {
            Toast.info('没有匹配可查询的渠道')
          }
          if(res.code == '3') {
            Toast.info('不是本机')
          }
          if(res.code == '4') {
            Toast.info('网关失败')
          }
          if(res.code == '5') {
            Toast.info('调用原有认证方式不调用网关验证')
          }
        })
      }
    } ,
    mounted () {
      //渲染
    }
  }
</script>
<style lang="less" scoped>
  .loginBtn {
    margin: 40px 0;
  }
</style>
